<?php

namespace app\http\middleware;

use think\facade\Cache;

class Check
{
    public function handle($request, \Closure $next)
    {
        $token = $request->param("token");

        if (empty($token)) {
            return json(["code" => 404 , "message" => "缺少必要字段"]);
        }

        if ($token !== Cache::get("token")) {
            return json(["code" => 404 , "message" => "token不准确"]);
        }
        return $next($request);
    }
}
